package edu.sctu.zcy.month201505.day20150524;

/**
 * Created by user24 on 2015/5/24.
 */
public class EncodedDemo {

    public static void main(String[] args) throws Exception{

        String str1 = "四川ABc";
        byte[] bytes = str1.getBytes();

        for(byte b : bytes){

            System.out.print(Integer.toHexString(b & 0xff) + "  ");
        }

        System.out.println();
        byte[] bytes1 = str1.getBytes("GBK");

        for(byte b : bytes1){

            System.out.print(Integer.toHexString(b & 0xff) + "  ");
        }

        System.out.println();
        byte[] bytes2 = str1.getBytes("utf-16be");

        for(byte b : bytes2){

            System.out.print(Integer.toHexString(b & 0xff) + "  ");
        }

        byte[] bytes4 = str1.getBytes();
        String s = new String(bytes4,"utf-8");
        System.out.println("\n"+s);

        String s1 = new String(bytes4,"utf-16be");
        System.out.println("\n"+s1);

        String s2 = new String(bytes4,"gbk");
        System.out.println("\n"+s2);
    }



}
